package 树;
/*/*
// Definition for a Node.
class Node {
    public int val;
    public List<Node> children;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, List<Node> _children) {
        val = _val;
        children = _children;
    }
};


class Solution {
    ArrayList<Integer> list=new ArrayList<>();
    public List<Integer> preorder(Node root) {
        if(root==null){
            return list;
        }
        list.add(root.val);
        for(Node node:root.children){
            if(node!=null){
                preorder(node);
            }

        }
        return list;
    }
}

没啥好说的 递归就完事了
 */



public class N叉树的前序遍历 {
    /**
     *  private List<List<Integer>> ret;
     *
     *     public List<List<Integer>> levelOrder(TreeNode root) {
     *         ret = new ArrayList<>();
     *         dfs(0, root);
     *         return ret;
     *     }
     *
     *     private void dfs(int depth, TreeNode root) {
     *         if (root == null) {
     *             return;
     *         }
     *         if (ret.size() == depth) {
     *             ret.add(new ArrayList<>());
     *         }
     *         ret.get(depth).add(root.val);
     *         dfs(depth + 1, root.left);
     *         dfs(depth + 1, root.right);
     *     }
     */
}
